import random

from selenium.webdriver.common.by import By

from base import BaseAction


class YxPageHome(BaseAction):
    next_ele = By.XPATH, '//span[text()="下一步"]'
    fac_ele = By.XPATH, '//input[@placeholder="请搜索并选择加工厂"]'
    quick_order_ele = By.XPATH, '//*[text()="快速下单"]'
    requirement_notes_ele = By.XPATH, '//*[@id="ZJaddWin"]//textarea'  # 需求备注
    upload_model_ele = By.XPATH, '//*[@id="ZJaddWin"]//div[1]/div[1]/div[2]/button[2]/span[text()="直接上传"]'
    upload_upper_ele = By.XPATH, '//*[@id="messageareaupload"]/div[1]/div[1]/div[1]/div[2]/div[@class="vueupbtn vueupbtn1"]'
    upload_lower_ele = By.XPATH, '//*[@id="messageareaupload"]/div[1]/div[1]/div[2]/div[2]/div[@class="vueupbtn vueupbtn2"]'
    upload_success_ele = By.XPATH, '//*[text()="100%"]'
    ok_ele = By.XPATH, '//div[2]/button/span[text()="确定"]'
    recent_visit_ele = By.XPATH, '//span[text()="好友列表"]'
    submit_ele = By.XPATH, '//span[text()="提交"]'
    submit_success_ele = By.XPATH, '//*[text()="归档完成！"]'

    # 点击下一步
    def get_next_ele(self):
        return self.get_element(self.next_ele)

    def get_fac_ele(self):
        return self.get_element(self.fac_ele)

    def get_use_fac_ele(self, fac_name):
        use_fac_ele = By.XPATH, f'//*[@id="ZJaddWin"]//div[3]/div[2]/span[text()="{fac_name}"][1]'
        return self.get_element(use_fac_ele)

    def get_quick_order_ele(self):
        return self.get_element(self.quick_order_ele)

    def get_requirement_notes_ele(self):
        return self.get_element(self.requirement_notes_ele)

    def get_upload_model_ele(self):
        return self.get_element(self.upload_model_ele)

    def get_upload_upper_ele(self):
        return self.get_element(self.upload_upper_ele)

    def get_upload_lower_ele(self):
        return self.get_element(self.upload_lower_ele)

    def get_upload_success_ele(self):
        return self.get_element(self.upload_success_ele)

    def get_ok_ele(self):
        return self.get_element(self.ok_ele)

    def get_recent_visit_ele(self):
        return self.get_element(self.recent_visit_ele)

    def get_technician_ele(self, js_name):
        technician_ele = By.XPATH, f'//span[text()="{js_name}"]'
        return self.get_element(technician_ele)

    def get_submit_ele(self):
        return self.get_element(self.submit_ele)

    def get_submit_success_ele(self):
        return self.get_element(self.submit_success_ele)
